package com.ruoyi.BeYYYDocComplaint.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.BeYYYDocComplaint.domain.BeHindDocComplaint;
import com.ruoyi.BeYYYDocComplaint.service.IBeHindDocComplaintService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 投诉记录Controller
 * 
 * @author ruoyi
 * @date 2025-08-17
 */
@RestController
@RequestMapping("/BeYYYDocComplaint/YYYBeComplaint")
public class BeHindDocComplaintController extends BaseController
{
    @Autowired
    private IBeHindDocComplaintService beHindDocComplaintService;

    /**
     * 查询投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(BeHindDocComplaint beHindDocComplaint)
    {
        startPage();
        List<BeHindDocComplaint> list = beHindDocComplaintService.selectBeHindDocComplaintList(beHindDocComplaint);
        return getDataTable(list);
    }

    /**
     * 导出投诉记录列表
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:export')")
    @Log(title = "投诉记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BeHindDocComplaint beHindDocComplaint)
    {
        List<BeHindDocComplaint> list = beHindDocComplaintService.selectBeHindDocComplaintList(beHindDocComplaint);
        ExcelUtil<BeHindDocComplaint> util = new ExcelUtil<BeHindDocComplaint>(BeHindDocComplaint.class);
        util.exportExcel(response, list, "投诉记录数据");
    }

    /**
     * 获取投诉记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:query')")
    @GetMapping(value = "/{complaintId}")
    public AjaxResult getInfo(@PathVariable("complaintId") Long complaintId)
    {
        return success(beHindDocComplaintService.selectBeHindDocComplaintByComplaintId(complaintId));
    }

    /**
     * 新增投诉记录
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:add')")
    @Log(title = "投诉记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeHindDocComplaint beHindDocComplaint)
    {
        return toAjax(beHindDocComplaintService.insertBeHindDocComplaint(beHindDocComplaint));
    }

    /**
     * 修改投诉记录
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:edit')")
    @Log(title = "投诉记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeHindDocComplaint beHindDocComplaint)
    {
        return toAjax(beHindDocComplaintService.updateBeHindDocComplaint(beHindDocComplaint));
    }

    /**
     * 删除投诉记录
     */
    @PreAuthorize("@ss.hasPermi('BeYYYDocComplaint:YYYBeComplaint:remove')")
    @Log(title = "投诉记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{complaintIds}")
    public AjaxResult remove(@PathVariable Long[] complaintIds)
    {
        return toAjax(beHindDocComplaintService.deleteBeHindDocComplaintByComplaintIds(complaintIds));
    }
}
